
package com.android.fitnesscenter.view.server;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.android.fitnesscenter.R;
import com.android.fitnesscenter.utils.ConfigProperties.AuditListResult;
import com.android.fitnesscenter.utils.MapEntity;
import com.android.fitnesscenter.utils.ToastHelper;
import com.android.fitnesscenter.view.BaseActivity;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;

public class ServerUnLockActivity extends BaseActivity {

    @ViewInject(R.id.btn_ok)
    private Button btn_ok;

    @ViewInject(R.id.btn_cancel)
    private Button btn_cancel;

    @ViewInject(R.id.txt_msg)
    private TextView txt_msg;

    private boolean isPass = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.unlock_user_layout);
        ViewUtils.inject(this);
        initTitleBar(getString(R.string.txt_new_user));
        queryLockedUsers(FROM_UNLOCK_ACTIVITY);
    }

    @Override
    protected void queryLockedUsersResult() {
        if (mUserList == null || mUserList.size() <= 0) {
            if (!isPass) {
                ToastHelper.getInstance().showShortMsg("没有新用户存在!");
            }
            finish();
            return;
        } else {
            MapEntity entity = mUserList.get(0);
            String loginName = entity.getString(AuditListResult.LOGIN_NAME);
            txt_msg.setText("新用户确认：" + loginName);
        }
    }

    @Override
    protected void updateUnLockedResult() {
        ToastHelper.getInstance().showShortMsg(mUserList.get(0).getString(AuditListResult.LOGIN_NAME) + "验证通过!");
        isPass = true;
        txt_msg.setText("");
        queryLockedUsers(FROM_UNLOCK_ACTIVITY);
    }

    @OnClick(R.id.btn_ok)
    public void btn_ok(View view) {
        updateUnLocked(mUserList.get(0));
    }

    @OnClick(R.id.btn_cancel)
    public void btn_cancel(View view) {
        finish();
    }

    @Override
    protected void titlebarMethod(int id) {

    }

}
